package com.soft.cqlinglong.oto.impl.mq;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;

/**
 * 接受消息，并发送消息
 */
public class QueueListenter implements MessageListener {


    public void onMessage(Message msg) {
        try {
            System.out.println(new String(msg.getBody(), "UTF-8"));
            String str = new String(msg.getBody(), "UTF-8");
            JSONObject json = JSONObject.parseObject(str);
            System.out.println(json.get("batchNo").toString());
            JSONArray jSONArray = JSONArray.parseArray(json.get("item").toString());
            System.out.println(jSONArray.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
